execute at @s anchored eyes positioned ^ ^ ^1 run summon marker ~ ~ ~ {Tags:["rmr.throw_axe_target"]}
scoreboard objectives add rmr.local.x_speed dummy
scoreboard objectives add rmr.local.z_speed dummy
scoreboard objectives add rmr.local.my_x dummy
scoreboard objectives add rmr.local.my_z dummy

execute store result score @s rmr.local.x_speed run data get entity @n[tag=rmr.throw_axe_target] Pos[0] 100
execute store result score @s rmr.local.z_speed run data get entity @n[tag=rmr.throw_axe_target] Pos[2] 100
execute store result score @s rmr.local.my_x run data get entity @s Pos[0] 100
execute store result score @s rmr.local.my_z run data get entity @s Pos[2] 100

scoreboard players operation @s rmr.local.x_speed -= @s rmr.local.my_x
scoreboard players operation @s rmr.local.z_speed -= @s rmr.local.my_z

execute unless score # rmr.entity.hell_mode matches 1 store result storage minecraft:rmr arguments.x_speed double 0.006 run scoreboard players get @s rmr.local.x_speed
execute unless score # rmr.entity.hell_mode matches 1 store result storage minecraft:rmr arguments.z_speed double 0.006 run scoreboard players get @s rmr.local.z_speed

execute if score # rmr.entity.hell_mode matches 1 store result storage minecraft:rmr arguments.x_speed double 0.012 run scoreboard players get @s rmr.local.x_speed
execute if score # rmr.entity.hell_mode matches 1 store result storage minecraft:rmr arguments.z_speed double 0.012 run scoreboard players get @s rmr.local.z_speed

execute if score # rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. store result storage minecraft:rmr arguments.x_speed double 0.02 run scoreboard players get @s rmr.local.x_speed
execute if score # rmr.entity.rotten_pillager_captain.hell_skill_counter matches 1.. store result storage minecraft:rmr arguments.z_speed double 0.02 run scoreboard players get @s rmr.local.z_speed

data modify storage minecraft:rmr arguments.y_speed set value 0d
data modify storage minecraft:rmr arguments.damage set value 5d

tag @s add rmr.connect.owner
execute at @s anchored eyes positioned ^ ^ ^ positioned ~ ~ ~ run function rmr:entity/flying_axe/spawn with storage minecraft:rmr arguments
tag @s remove rmr.connect.owner

scoreboard objectives remove rmr.local.x_speed
scoreboard objectives remove rmr.local.z_speed
scoreboard objectives remove rmr.local.my_x
scoreboard objectives remove rmr.local.my_z

kill @n[tag=rmr.throw_axe_target]